<?php
namespace Admin\Frontend\Controllers;

use Admin\Models\sys\XhsysEnum;
use Admin\Models\user\XhsysUser;
use Helpers\Hrm;
use Helpers\Main;
use Helpers\Tool;
use Helpers\Assets;
use Helpers\Template;
use Admin\Models\sys\XhsysPower;
use Admin\Models\group\XhsysGroup;
use Admin\Models\group\XhsysGroupuser;
use Admin\Models\group\XhsysGrouppower;
use Helpers\User;
use Modules\Power;

class GroupController extends ControllerBase
{

    private function getGroupEnum()
    {
        return [
            'iType' => XhsysEnum::getEnumByNodeName('用户组')
        ];
    }

    /**
     * 权限组列表
     *
     * @return \Phalcon\Mvc\View|string
     *
     * create by ck 20171107
     */
    public function indexAction()
    {
        $this->view->pick('group/index');
        Assets::easyUI('js/group/index.js');
        $type = $this->request->getQuery('type', 'int');
        $powerTag = $type == 2 ? 'Hrm_Group' : 'User_Group';
        if (!Power::exist($powerTag)) {
            return $this->sendViewError('无查看权限');
        }

        $listButtonArr = $listSearchArr = [];
        $listSearchArr[] = ['type' => 'text', 'id' => 'list_vague', 'label' => ' 搜索：'];
        $listSearchArr[] = ['type' => 'button', 'id' => 'bt_list_search', 'text' => '查找',
            'icon' => 'fa-search', 'style' => 'margin-left:10px'];
        if (Power::exist($powerTag . '_Add')) {
            $listButtonArr[] = ['id' => 'bt_list_add', 'text' => '新增', 'icon' => 'fa-plus'];
        }
        if (Power::exist($powerTag . '_Edit')) {
            $listButtonArr[] = ['id' => 'bt_list_move', 'text' => '转移至部门', 'icon' => 'fa-arrow-circle-left'];
            $listButtonArr[] = ['id' => 'bt_list_reset', 'text' => '重置部门', 'icon' => 'fa-refresh'];
            $listButtonArr[] = ['id' => 'bt_list_edit', 'text' => '修改', 'icon' => 'fa-edit'];
        }
        if (Power::exist($powerTag . '_SetPower')) {
            $listButtonArr[] = ['id' => 'bt_list_set_power', 'text' => '设置权限', 'icon' => 'fa-pencil'];
        }
        if (Power::exist($powerTag . '_Del')) {
            $listButtonArr[] = ['id' => 'bt_list_del', 'text' => '删除', 'icon' => 'fa-trash'];
        }
        $listButtonArr[] = ['id' => 'bt_list_user', 'text' => '查看成员', 'icon' => 'fa-eye'];
        return $this->view->setVars([
            'DepList' => Template::createList('depList', 'Group_Dep'),
            'List' => Template::createList('list', 'Group_List', [
                'searchToolbar' => Template::createSearchToolBar($listSearchArr, !!$listButtonArr),
                'buttonToolbar' => Template::createButtonToolBar($listButtonArr)
            ]),
        ]);


//        $type = $this->request->getQuery('type', 'int');
//        $powerTag = $type == 2 ? 'Hrm_Group' : 'User_Group';
//        if (!Power::exist($powerTag)) {
//            return $this->sendViewError('无查看权限');
//        }
//        $this->view->setTemplateBefore('listForm');
//        Main::showNavPosition();
//        Assets::easyUI('js/group/index.js');
//        $listButtonArr = $listSearchArr = [];
//        if (Power::exist($powerTag . '_Add')) {
//            $listButtonArr[] = ['id' => 'bt_list_add', 'text' => '增加', 'icon' => 'fa-plus'];
//        }
//        if (Power::exist($powerTag . '_SetPower')) {
//            $listButtonArr[] = ['id' => 'bt_list_set_power', 'text' => '设置权限', 'icon' => 'fa-pencil'];
//        }
//        $listButtonArr[] = ['id' => 'bt_list_user', 'text' => '查看成员', 'icon' => 'fa-eye'];
//        $listSearchArr[] = ['type' => 'select', 'id' => 'list_type', 'data' => ['' => '--类型--'] + $this->getGroupEnum()['iType']];
//        $listSearchArr[] = ['type' => 'text', 'id' => 'list_vague', 'label' => ' 搜索：'];
//        return $this->view->setVars([
//            'List'  => Template::createList('list', 'Group_List', [
//                'searchToolbar' => Template::createSearchToolBar($listSearchArr, !!$listButtonArr),
//                'buttonToolbar' => Template::createButtonToolBar($listButtonArr)
//            ]),
//        ]);
    }

    /**
     * 获取部门权限组列表
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20181106
     */
    public function getDepGroupAction()
    {
        $type   = $this->request->getPost('type', 'string');
        try {
            $data   = Hrm::getDepArray(null, 1, true);
            $data   = array_column($data, null, 'id');
            $depIds = array_keys($data);
            $data   = array_map(function ($item) {
                return [
                    'id' => 'dep_' . $item['id'],
                    'iDepId' => $item['id'],
                    'name' => $item['text'],
                    'iconCls' => 'fa fa-group'
                ];
            }, $data);
            if ($depIds) {
                $params = [
                    'columns' => 'iGroupId,sName,iDepId,iType',
                    'conditions' => 'bDelete = 0 AND iDepId IN ({depIds:array})',
                    'bind' => ['depIds' => $depIds]
                ];
                if (!User::isAdmin() && $type) {
                    $params['conditions'] .= ' AND iType = :type:';
                    $params['bind']['type'] = $type;
                }
                $groups = XhsysGroup::find($params)->toArray();
                Tool::runEnum($groups, Power::$groupEnum);
                foreach ($groups as $group) {
                    $data[$group['iDepId']]['children'][] = [
                        'id' => 'group_' . $group['iGroupId'],
                        'iGroupId' => $group['iGroupId'],
                        'name' => $group['sName'],
                        'iType' => $group['iType']
                    ];
                    $data[$group['iDepId']]['state'] = 'closed';
                }
            }
            $data = array_values($data);
            return $this->sendJsonResponse($data);
        } catch (\Exception $e) {
            return $this->sendErrorResponse(500, '系统异常', $e->getMessage());
        }
    }

    /**
     * 获取所有部门权限组
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20181108
     * modify by ck 20181112
     * modify by ck 20181227
     */
    public function getAllDepGroupAction()
    {
        $type   = $this->request->getPost('type', 'string');
        try {
            $data   = Hrm::getDepArray(null, 1, true);
            $data   = array_column($data, null, 'id');
            $data   = array_map(function ($item) {
                return [
                    'id' => 'dep_' . $item['id'],
                    'iDepId' => $item['id'],
                    'name' => $item['text'],
                    'iconCls' => 'fa fa-group'
                ];
            }, $data);
            $params = [
                'columns' => 'iGroupId,sName,iDepId,iType',
                'conditions' => 'bDelete = 0'
            ];
            if (!User::isAdmin() && $type) {
                $params['conditions'] .= ' AND iType = :type:';
                $params['bind']['type'] = $type;
            }
            $groups = XhsysGroup::find($params)->toArray();
            Tool::runEnum($groups, Power::$groupEnum);
            foreach ($groups as $group) {
                $depId = $group['iDepId'];
                $row = [
                    'id' => 'group_' . $group['iGroupId'],
                    'iGroupId' => $group['iGroupId'],
                    'name' => $group['sName'],
                    'iType' => $group['iType']
                ];
                if ($depId && isset($data[$depId])) {
                    $data[$depId]['children'][] = $row;
                    $data[$depId]['state'] = 'closed';
                } else {
                    $data[] = $row;
                }
            }
            $data = array_values($data);
            return $this->sendJsonResponse($data);
        } catch (\Exception $e) {
            return $this->sendErrorResponse(500, '系统异常', $e->getMessage());
        }
    }

    /**
     * 获取用户组类型
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20180110
     */
    public function getGroupTypeAction()
    {
        return $this->sendJsonResponse($this->getGroupEnum()['iType']);
    }

    /**
     * 获取权限组
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20171107
     * modify by ck 20181108    添加部门信息
     */
    public function getGroupAction()
    {
        $type = $this->request->getPost('type', 'int');
        $parameters = [
            'columns'    => 'iGroupId,sName,iType,iDepId,iCreateUserId,tCreateDate',
            'conditions' => 'bDelete = 0'
        ];
        if ($type) {
            $parameters['conditions']  .= ' AND iType = :type:';
            $parameters['bind']['type'] = $type;
        }
        Main::runSearchVagueConditions($parameters['conditions'], ['sName']);
        $data = Main::runModelPage('\\Admin\\Models\\group\\XhsysGroup', $parameters, $this->getGroupEnum());
        Main::runUserNameById($data['rows'], 'iCreateUserId', true);
        Hrm::runDepName($data['rows'], ['iDepId' => 'sDepName']);
        return $this->sendJsonResponse($data);
    }

    /**
     * 创建权限组
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20171107
     */
    public function createGroupAction()
    {
        $name = $this->request->getPost('name', 'string');
        $type = $this->request->getPost('type', 'int');
        if (!$name || !$type) {
            return $this->sendErrorResponse(400, '缺少必要参数');
        }
        $powerTag = $type == 2 ? 'Hrm_Group' : 'User_Group';
        if (!Power::exist($powerTag . '_Add')) {
            return $this->sendErrorResponse(403, '无创建权限');
        }
        try {
            $obj = new XhsysGroup();
            $obj->sName = $name;
            $obj->iType = $type;
            if (!$obj->save()) {
                throw new \Exception('保存失败');
            }
            return $this->sendSuccessResponse('创建成功');
        } catch (\Exception $e) {
            return $this->sendErrorResponse(500, $e->getMessage());
        }
    }

    /**
     * 设置权限组部门id
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20181106
     */
    public function setGroupDepAction()
    {
        $groupIds = $this->request->getPost('groupIds', 'int');
        $depId = $this->request->getPost('depId', 'int');
        if (!$groupIds || !$depId) {
            return $this->sendErrorResponse(400, '缺少参数');
        }
        try {
            $groupIds = implode(',', $groupIds);
            $result = $this->db->update(
                'XHSys_Group',
                ['iDepId'],
                [$depId],
                "iGroupId IN ({$groupIds})"
            );
            if (!$result) {
                throw new \Exception('更改失败');
            }
            return $this->sendSuccessResponse('操作成功');
        } catch (\Exception $e) {
            return $this->sendErrorResponse(500, '系统异常', $e->getMessage());
        }
    }

    /**
     * 修改组信息
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20181107
     */
    public function modifyGroupAction()
    {
        $groupId = $this->request->getPost('groupId', 'int');
        $name = $this->request->getPost('name', 'string');
        $type = $this->request->getPost('type', 'int');
        if (!$groupId || !$name || !$type) {
            return $this->sendErrorResponse(400, '缺少必要参数');
        }
        try {
            $group = XhsysGroup::findFirst($groupId);
            $group->sName = $name;
            $group->iType = $type;
            if (!$group->save()) {
                throw new \Exception($group->getError());
            }
            return $this->sendSuccessResponse('修改成功');
        } catch (\Exception $e) {
            return $this->sendErrorResponse(500, '系统异常', $e->getMessage());
        }
    }

    /**
     * 删除权限组
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20181106
     */
    public function delGroupAction()
    {
        $groupIds = $this->request->getPost('groupIds', 'int');
        if (!$groupIds) {
            return $this->sendErrorResponse(400, '缺少组id');
        }
        try {
            $result = XhsysGroup::deleteRecord('iGroupId', $groupIds);
            if (!$result) {
                throw new \Exception('删除失败');
            }
            return $this->sendSuccessResponse('删除成功');
        } catch (\Exception $e) {
            return $this->sendErrorResponse(500, '系统异常', $e->getMessage());
        }
    }

    /**
     * 重置权限组部门
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20181108
     */
    public function resetGroupDepAction()
    {
        $groupIds = $this->request->getPost('groupIds', 'int');
        if (!$groupIds) {
            return $this->sendErrorResponse(400, '缺少参数');
        }
        try {
            $groupIds = implode(',', $groupIds);
            $result = $this->db->update(
                'XHSys_Group',
                ['iDepId'],
                [0],
                "iGroupId IN ({$groupIds})"
            );
            if (!$result) {
                throw new \Exception('更改失败');
            }
            return $this->sendSuccessResponse('操作成功');
        } catch (\Exception $e) {
            return $this->sendErrorResponse(500, '系统异常', $e->getMessage());
        }
    }

    /**
     * 权限组权限编辑页面
     *
     * @return \Phalcon\Mvc\View|string
     *
     * create by ck 20171107
     */
    public function groupPowerAction()
    {
        $this->view->pick('group/groupPower');
        Main::showNavPosition('角色列表', '设置组权限');
        Assets::importJs('js/group/groupPower.js');
        $groupId = $this->request->getQuery('groupId', 'int');
        if (!$groupId) {
            return $this->sendViewError('缺少权限组id');
        }
        return $this->view->setVar('powerTree', XhsysPower::createGroupPowerTree($groupId));
    }

    /**
     * 保存权限组权限
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20171107
     */
    public function saveGroupPowerAction()
    {
        $groupId    = $this->request->getPost('groupId', 'int');
        $powerTags  = $this->request->getPost('powerTag', 'string');
        $powerTags  or $powerTags = [];
        if (!$groupId) {
            return $this->sendErrorResponse(400, '缺少组id');
        }
        $obj = XhsysGrouppower::findFirst($groupId) ?: new XhsysGrouppower(['iGroupId' => $groupId]);
        $obj->mPowerTag = implode(',', $powerTags);
        if (!$obj->save()) {
            return $this->sendErrorResponse(500, '保存权限失败');
        }
        return $this->sendSuccessResponse('保存成功');
    }

    /**
     * 设置用户权限组页面
     *
     * @return \Phalcon\Mvc\View|string
     *
     * create by ck 20171107
     * modify by ck 20181029    超管可查看所有用户组
     * modify by ck 20181107    重构
     */
    public function userGroupAction()
    {
        $type    = $this->request->getQuery('type', 'int');
        $userIds = $this->request->getQuery('userIds', 'string');
        if (!$userIds) {
            return $this->sendViewError('缺少用户id');
        }
        if ($type == 3) {
            $this->view->pick('group/userGroupTch');
            Assets::easyUI('js/group/userGroupTch.js');
            $groupParams = [
                'columns' => 'iGroupId AS groupId,sName AS groupName',
                'conditions' => 'bDelete = 0'
            ];

//            if (!User::isAdmin() && $type) {
            if ($type) {
                $groupParams['conditions'] .= ' AND iType = :type:';
                $groupParams['bind']['type'] = $type;
            }
//            if (User::isAdmin()) {
//                $groupParams['order'] = 'iType';
//            }
            $groupList = XhsysGroup::find($groupParams)->toArray();
            if (!$groupList) {
                return $this->sendViewError('暂无权限组，不可设置');
            }

            //如为单用户设置，则处理已有角色组
            if (count(explode(',', $userIds)) == 1) {
                $existGroupIds = XhsysGroupuser::find([
                    'columns' => 'iGroupId AS groupId',
                    'conditions' => 'bDelete = 0 AND iUserId = :userId:',
                    'bind' => ['userId' => $userIds]
                ])->toArray();
                $groupList = array_column($groupList, null, 'groupId');
                $existGroupIds = array_column($existGroupIds, 'groupId');
                foreach ($existGroupIds as $groupId) {
                    if (isset($groupList[$groupId])) {
                        $groupList[$groupId]['checked'] = true;
                    }
                }
                $groupList = array_values($groupList);
            }
            return $this->view->setVar('groups', $groupList);
        } else {
            $this->view->pick('group/userGroup');
            Assets::easyUI('js/group/userGroup.js');
            return $this->view->setVars([
                'DepList' => Template::createList('depList', 'Group_Dep', [
                    'tableAttr' => [
                        'singleSelect' => 'false'
                    ]
                ])
            ]);
        }

//        $type    = $this->request->getQuery('type', 'int');
//        $userIds = $this->request->getQuery('userIds', 'string');
//        if (!$userIds) {
//            return $this->sendViewError('缺少用户id');
//        }
//        $this->view->pick('group/userGroup');
//        Assets::importJs('js/group/userGroup.js');
//        $groupParams = [
//            'columns'    => 'iGroupId AS groupId,sName AS groupName',
//            'conditions' => 'bDelete = 0'
//        ];
//
//        if (!User::isAdmin() && $type) {
//            $groupParams['conditions']  .= ' AND iType = :type:';
//            $groupParams['bind']['type'] = $type;
//        }
//        if (User::isAdmin()) {
//            $groupParams['order'] = 'iType';
//        }
//        $groupList = XhsysGroup::find($groupParams)->toArray();
//        if (!$groupList) {
//            return $this->sendViewError('暂无权限组，不可设置');
//        }
//
//        //如为单用户设置，则处理已有角色组
//        if (count(explode(',', $userIds)) == 1) {
//            $existGroupIds = XhsysGroupuser::find([
//                'columns'    => 'iGroupId AS groupId',
//                'conditions' => 'bDelete = 0 AND iUserId = :userId:',
//                'bind'       => ['userId' => $userIds]
//            ])->toArray();
//            $groupList      = array_column($groupList, null, 'groupId');
//            $existGroupIds  = array_column($existGroupIds, 'groupId');
//            foreach ($existGroupIds as $groupId) {
//                if (isset($groupList[$groupId])) {
//                    $groupList[$groupId]['checked'] = true;
//                }
//            }
//            $groupList = array_values($groupList);
//        }
//        return $this->view->setVar('groups', $groupList);
    }

    /**
     * 获取用户存在组
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface
     *
     * create by ck 20181107
     */
    public function getUserGroupAction()
    {
        $userId = $this->request->getPost('userId', 'int');
        if (!$userId) {
            return $this->sendErrorResponse(400, '缺少用户id');
        }
        try {
            $params = [
                'columns'    => 'iGroupId AS groupId',
                'conditions' => 'bDelete = 0 AND iUserId = :userId:',
                'bind'       => ['userId' => $userId]
            ];
            $groupIds = XhsysGroupuser::find($params)->toArray();
            $groupIds = array_column($groupIds, 'groupId');
            return $this->sendJsonResponse($groupIds);
        } catch (\Exception $e) {
            return $this->sendErrorResponse(500, '系统异常', $e->getMessage());
        }
    }

    /**
     * 保存用户用户组
     *
     * @return \Phalcon\Http\Response|\Phalcon\Http\ResponseInterface|string
     *
     * create by ck 20171107
     * modify by ck 20181029    admin去除类型限制
     */
    public function saveUserGroupAction()
    {
        $type    = $this->request->getPost('type', 'int');
        $userIds = $this->request->getPost('userIds', 'string');
        $groupIds= $this->request->getPost('groupId', 'int');
        if (!$userIds) {
            return $this->sendViewError('缺少用户id');
        }
        $userIds  = explode(',', $userIds);
        $groupIds or $groupIds = [];
        try {
            $this->db->begin();
            //单用户则删除已有角色组
            if (count($userIds) == 1) {
                $groupIdArea = [];
                //查找对应类型权限组作为条件
                if (!User::isAdmin() && $type) {
                    $groupIdArea = XhsysGroup::find([
                        'columns'    => 'iGroupId',
                        'conditions' => 'bDelete = 0 AND iType = :type:',
                        'bind'       => ['type' => $type]
                    ])->toArray();
                    $groupIdArea = array_column($groupIdArea, 'iGroupId');
                }
                $parameters = [
                    'conditions' => 'bDelete = 0 AND iUserId = :userId:',
                    'bind'       => ['userId' => $userIds[0]]
                ];
                if ($groupIdArea) {
                    $parameters['conditions']     .= ' AND iGroupId IN ({groupId:array})';
                    $parameters['bind']['groupId'] = $groupIdArea;
                }
                if (!XhsysGroupuser::find($parameters)->delete()) {
                    throw new \Exception('删除原有权限失败');
                }
            }
            //为用户添加权限组
            foreach ($userIds as $userId) {
                foreach ($groupIds as $groupId) {
                    if (XhsysGroupuser::findFirst("bDelete = 0 AND iGroupId = '{$groupId}' AND iUserId = '{$userId}'")) {
                        continue;
                    }
                    if (!(new XhsysGroupuser(['iGroupId' => $groupId, 'iUserId' => $userId]))->save()) {
                        throw new \Exception('添加失败');
                    }
                }
            }
            $this->db->commit();
            return $this->sendSuccessResponse('保存成功！');
        } catch (\Exception $e) {
            $this->db->rollback();
            return $this->sendErrorResponse(500, $e->getMessage());
        }
    }

    /**
     * 查看用户组用户
     *
     * @return \Phalcon\Mvc\View|string
     *
     * create by ck 20180817
     */
    public function groupUserAction()
    {
        $groupId = $this->request->getQuery('groupId', 'int');
        if (!$groupId) {
            return $this->sendViewError('缺少组id');
        }
        $this->view->pick('group/groupUser');
        try {
            $userIds = XhsysGroupuser::find([
                'columns' => 'iUserId,tCreateDate',
                'conditions' => 'iGroupId = :groupId: AND bDelete = 0',
                'bind' => ['groupId' => $groupId]
            ])->toArray();
            if (!$userIds) {
                return $this->sendViewError('该组暂无用户');
            }
            $enterDate = array_column($userIds, 'tCreateDate', 'iUserId');
            $userIds = array_column($userIds, 'iUserId');
            $users = $this->modelsManager->createBuilder()
                ->columns(['u.iUserId', 'u.sLogonName', 'u.sUserName', 'u.sLogonPwd', 'u.sSelfPhone',
                    's.sStaffName', 's.iStaffStatus'])
                ->from(['u' => '\\Admin\\Models\\user\\XhsysUser'])
                ->leftJoin('\\Admin\\Models\\hrm\\XhhrmStaff', 'u.iUserId = s.iUserId AND s.bDelete = 0', 's')
                ->where('u.bDelete = 0 AND u.iUserId IN ({userIds:array})', ['userIds' => $userIds])
                ->getQuery()->execute()->toArray();
            Tool::runEnum($users, ['iStaffStatus' => [1 => '-在职', 2 => '-离职', 3 => '-退休']]);
            foreach ($users as &$user) {
                $user['tCreateDate'] = $enterDate[$user['iUserId']];
            }
//            $users = XhsysUser::find([
//                'columns' => 'iUserId,sLogonName,sSelfPhone,sUserName',
//                'conditions' => 'iUserId IN ({userIds:array}) AND bDelete = 0 AND bDisable = 0 AND bHistory = 0',
//                'bind' => ['userIds' => $userIds]
//            ])->toArray();
            return $this->view->setVar('users', $users);
        } catch (\Exception $e) {
            return $this->sendViewError($e->getMessage());
        }
    }

//    public function depGroupAction()
//    {
//        $type = $this->request->getQuery('type', 'int');
//        $powerTag = $type == 2 ? 'Hrm_Group' : 'User_Group';
//        if (!Power::exist($powerTag)) {
//            return $this->sendViewError('无查看权限');
//        }
//        $this->view->pick('group/depGroup');
//        Main::showNavPosition();
//        Assets::easyUI('js/group/depGroup.js');
//        $listButtonArr = $listSearchArr = [];
//        if (Power::exist($powerTag . '_Add')) {
//            $listButtonArr[] = ['id' => 'bt_list_add', 'text' => '增加', 'icon' => 'fa-plus'];
//        }
//        if (Power::exist($powerTag . '_SetPower')) {
//            $listButtonArr[] = ['id' => 'bt_list_set_power', 'text' => '设置权限', 'icon' => 'fa-pencil'];
//        }
//        $listButtonArr[] = ['id' => 'bt_list_user', 'text' => '查看成员', 'icon' => 'fa-eye'];
//        $listSearchArr[] = ['type' => 'select', 'id' => 'list_type', 'data' => ['' => '--类型--'] + $this->getGroupEnum()['iType']];
//        $listSearchArr[] = ['type' => 'text', 'id' => 'list_vague', 'label' => ' 搜索：'];
//        return $this->view->setVars([
//            'depList'   => Template::createList('dep_list', 'Power_Dep'),
//            'groupList' => Template::createList('group_list', 'Group_List', [
//                'searchToolbar' => Template::createSearchToolBar($listSearchArr, !!$listButtonArr),
//                'buttonToolbar' => Template::createButtonToolBar($listButtonArr)
//            ])
//        ]);
//    }
}